
<template>
	<view class="pay-result column-center">
		<view class="contain bg-white">
			<view class="header  column-center">
				<view>
					<image class="tips-icon" src="/static/images/icon_paySuccess.png"></image>
				</view>
				<view class="xl mt20">订单支付成功</view>
			</view>
			<view style="height:181rpx"></view>
			<view class="info">
				<view class="order-num row-between mt20">
					<view class="ml20">订单编号</view>
					<view class="mr20">{{payInfo.pay_sn}}</view>
				</view>
				<view v-if="payInfo.pay_time" class="order-time row-between mt20">
					<view class="ml20">付款时间</view>
					<view class="mr20">{{payInfo.pay_time}}</view>
				</view>
				<view class="order-pay-type row-between mt20">
					<view class="ml20">支付方式</view>
					<view class="mr20">{{ getPayWay(payInfo.pay_way) }}</view>
				</view>
				<view class="order-pay-money row-between mt20">
					<view class="ml20">支付金额</view>
					<view class="mr20">
						<price-format :price="payInfo.pay_amount"></price-format>
					</view>
				</view>
			</view>
			<view class="line ml20"></view>
			<view class="opt-btn-contain row-center wrap">
				<view class="check-order-btn row-center bg-primary br60 mt20" @tap="showOrder(id)">
					<view class="white bg-primary lg">查看订单</view>
				</view>
				<view class="go-back-btn row-center br60 mt20" @tap="goHome">
					<view class="primary br60 lg">返回首页</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { leaseBuyOutDetail } from '@/api/lease.js';
	
	export default {
		data() {
			return {
				id: '',			// 订单ID
				payInfo: {},	// 订单信息数据
			};
		},
		
		methods: {
			// 获取支付方式
			getPayWay(type) {
				switch(type) {
					case 1: return '微信支付';
					case 2: return '支付宝支付';
					case 3: return '余额支付';
				}
			},
			
			// 查看订单
			showOrder(id) {
				uni.redirectTo({
					url: `/bundle/pages/lease_buy_detail/lease_buy_detail?id=${id}`
				})
			},
			
			// 返回主页
			goHome() {
				uni.switchTab({ url: `/pages/index/index` });
			} 
		},
		
		onLoad(options) {
			this.id = options.id;
			// 请求订单数据初始化数据
			leaseBuyOutDetail({ id: this.id }).then(res => {
				if (res.code != 1) return;
				const data = res.data;
				this.payInfo = data.amount_info;
			});
		}
	};
</script>
<style lang="scss">
	.pay-result {
		.contain {
			width: 682rpx;
			margin-left: 20rpx;
			margin-right: 20rpx;
			border-radius: 10rpx;
			margin-top: 78rpx;
			padding-left: 20rpx;
			padding-right: 20rpx;
			padding-bottom: 40rpx;
			position: relative;

			.tips-icon {
				width: 112rpx;
				height: 112rpx;
			}

			.header {
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				top: -50rpx;
			}

			.order-num {
				align-items: flex-start;
			}

			.info {
				margin-bottom: 40rpx;
			}

			.opt-btn-contain {
				margin-top: 40rpx;

				.check-order-btn {
					width: 650rpx;
					height: 84rpx;
				}

				.go-back-btn {
					width: 650rpx;
					height: 84rpx;
					border:1px solid  $-color-primary;
					box-sizing: border-box;
				}
			}

			.line {
				width: 650rpx;
				border-top: 1px solid rgba(229, 229, 229, 1);
			}
		}
	}
</style>
